package cn.boodqian.airdata;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.ServletContext;
import javax.servlet.http.*;

@SuppressWarnings("serial")
public class FetchServlet extends HttpServlet {
    private final static Logger Log = Logger.getLogger(FetchServlet.class .getName());
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setContentType("text/plain");
		resp.setCharacterEncoding("UTF-8");
		
		String path = req.getPathInfo();
		ServletContext context = this.getServletContext();
		if(path!=null) {
		    if (path.compareTo("/bj")==0) {
				new BeijingAirDataProvider(context).doFetch(24);
			}
			else if (path.compareTo("/us")==0) {
				new ShanghaiUSAirDataProvider(context).doFetch(24);
			}
			else if (path.compareTo("/cnemc")==0) {
				new CNEMCAirDataProvider(context).doFetch(24);
			}
		}
		resp.getWriter().println(path + " Done");
	}
}
